package com.hdu.guahao.hosp.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.hdu.guahao.common.result.Result;
import com.hdu.guahao.hosp.service.HospitalService;
import com.hdu.hospital.model.hosp.Hospital;
import com.hdu.hospital.vo.hosp.HospitalQueryVo;
import com.hdu.hospital.vo.hosp.HospitalSetQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    //医院列表
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalSetQueryVo){
       Page<Hospital> pageModel = hospitalService.selectHospPage(page,limit,hospitalSetQueryVo);
       return Result.ok(pageModel);
    }

    //更新医院状态
    @ApiOperation("更新医院状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    //医院详情信息
    @GetMapping("showHospDetail/{id}")
    @ApiOperation("医院详情")
    public Result showHospDetail(@PathVariable String id){
        Map<String,Object> hospital = hospitalService.getHospById(id);
        return Result.ok(hospital);
    }
}
